local skill = fk.CreateSkill {
  name = "lvshi__yanzheng",
}

Fk:loadTranslationTable{

  ["lvshi__yanzheng"] = "严整",
  [":lvshi__yanzheng"] = "当己方角色进入濒死状态时，你可令其废除装备区并回复X点体力（X为以此法弃置的装备牌数+1），然后其本局游戏装备牌不计入手牌上限，且可将装备牌当【无懈可击】使用。",
  ["lvshi__yanzheng_buff&"] = "严整",
  ["#lvshi__yanzheng"] = "严整：你可令%src废除装备区并回复体力",
  [":lvshi__yanzheng_buff&"] = "你可将一张装备牌当【无懈可击】使用",

  ["$lvshi__yanzheng1"] = "千里之行，必积跬步，军风蔚然，必成强军。",
  ["$lvshi__yanzheng2"] = "众军成城，肃风整备，其皆可以一当十。",
}


local ls = require "packages/lvshi/utility"

skill:addEffect(fk.EnterDying, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skill.name) and (player == target or ls.isFriend(player, target)) and target:getMark("lvshi__yanzheng") == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = skill.name,
      prompt = "#lvshi__yanzheng:"..target.id})
  end,  
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(target, "lvshi__yanzheng")
    local eqipSlots = target:getAvailableEquipSlots()
    local n = #target:getCardIds("e") + 1
    room:abortPlayerArea(target, eqipSlots)
    if n > 0 then
      room:recover({
        who = target,
        num = n,
        recoverBy = player,
        skillName = skill.name
      }) 
    end
    room:handleAddLoseSkills(target, "lvshi__yanzheng_buff&")
  end,
})

return skill